Page({

    data: {
        list: null,
        userName: null,
        userPhone: null,
        boxId: null,
        orderId: null,
        price: null,
        date: null,
        display: []
    },

    onLoad (query) {
        let data = JSON.parse(query.data);
        console.log(data);
        for (let i = 0; i < data.orderDetails.length; i++)
        {
            let price = 0;
            price = data.orderDetails[i].detailPrice / data.orderDetails[i].detailNum;
            data.orderDetails[i].detailPrice = price.toFixed(2);
            price = data.orderDetails[i].goods.goodsPrice * 0.95;
            data.orderDetails[i].detailPerson = price.toFixed(2);
        }
        let display = [];
        if (data.orderState == 1) {
            display = false
        } else {
            for (let i = 0; i < data.orderState; i++)
            {
                display[i] = true;
            }
        }
        this.setData({
            userName: data.orderUserName,
            userPhone: data.orderPhone,
            boxId: data.orderBoxId,
            orderId: data.orderId,
            price: data.orderPrice,
            date: data.orderDate,
            list: data.orderDetails,
            display: display  
        })
    },

    cart () {
        wx.switchTab({
            url: '../cart/cart'
        })
    },

    category () {
        wx.switchTab({
            url: '../category/category'
        })
    }
  
})